package com.njxxted.activiti.modules.process.extend.controller;

import com.njxxted.activiti.common.response.ResponseVo;
import com.njxxted.activiti.common.util.PageUtil;
import com.njxxted.activiti.modules.base.controller.BaseController;
import com.njxxted.activiti.modules.process.extend.entity.ExtendActNodeBtnEntity;
import com.njxxted.activiti.modules.process.extend.service.ExtendActNodeBtnService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;


/**
 * 描述：按钮配置表 exception
 * <p>
 * 作者：HuTongFu
 * 邮箱：hu_tongfu@163.com
 * 时间：2019-08-07 09:34:07
 */
@Api(tags = "流程按钮配置")
@RestController
@RequestMapping("/act/rest/extend/btn")
public class ExtendActNodeBtnController extends BaseController {

    @Resource
    private ExtendActNodeBtnService extendActNodeBtnService;

    @ApiOperation(value = "分页查询")
    @GetMapping("/")
    public ResponseVo list(ExtendActNodeBtnEntity param) {
        PageUtil<ExtendActNodeBtnEntity> actNodeBtnList = extendActNodeBtnService.queryList(param);
        return ResponseVo.ok(actNodeBtnList);
    }

    @ApiOperation(value = "根据主键id查询")
    @GetMapping("/{id}")
    public ResponseVo info(@PathVariable("id") String id) {
        ExtendActNodeBtnEntity extendActNodeBtnEntity = extendActNodeBtnService.queryObject(id);
        return ResponseVo.ok(extendActNodeBtnEntity);
    }

    @ApiOperation(value = "保存")
    @PostMapping("/")
    public ResponseVo save(ExtendActNodeBtnEntity param) {
        int i = extendActNodeBtnService.save(param);
        if (i > 0)
            return ResponseVo.ok();
        else
            return ResponseVo.error();
    }

    @ApiOperation(value = "修改")
    @PutMapping("/")
    public ResponseVo update(ExtendActNodeBtnEntity extendActNodeBtnEntity) {
        int i = extendActNodeBtnService.update(extendActNodeBtnEntity);
        if (i > 0)
            return ResponseVo.ok();
        else
            return ResponseVo.error();
    }

    @ApiOperation(value = "删除")
    @DeleteMapping("/")
    public ResponseVo delete(@RequestParam("ids") String[] ids) {
        int i = extendActNodeBtnService.deleteBatch(ids);
        if (i > 0)
            return ResponseVo.ok();
        else
            return ResponseVo.error();
    }

}
